package cn.iocoder.yudao.module.monitor.dal.mysql.realtime;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.monitor.dal.dataobject.realtime.RealTimeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.monitor.controller.admin.realtime.vo.*;

/**
 * 监控 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface RealTimeMapper extends BaseMapperX<RealTimeDO> {

    default PageResult<RealTimeDO> selectPage(RealTimePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RealTimeDO>()
                .eqIfPresent(RealTimeDO::getArea, reqVO.getArea())
                .eqIfPresent(RealTimeDO::getBox, reqVO.getBox())
                .likeIfPresent(RealTimeDO::getNo, reqVO.getNo())
                .eqIfPresent(RealTimeDO::getType, reqVO.getType())
                .likeIfPresent(RealTimeDO::getIp, reqVO.getIp())
                .likeIfPresent(RealTimeDO::getSerialNumber, reqVO.getSerialNumber())
                .orderByDesc(RealTimeDO::getId));
    }

    default List<RealTimeDO> selectList(RealTimeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RealTimeDO>()
                .eqIfPresent(RealTimeDO::getArea, reqVO.getArea())
                .eqIfPresent(RealTimeDO::getBox, reqVO.getBox())
                .likeIfPresent(RealTimeDO::getNo, reqVO.getNo())
                .eqIfPresent(RealTimeDO::getType, reqVO.getType())
                .likeIfPresent(RealTimeDO::getIp, reqVO.getIp())
                .likeIfPresent(RealTimeDO::getSerialNumber, reqVO.getSerialNumber())
                .orderByDesc(RealTimeDO::getId));
    }

}
